﻿// Decompiled with JetBrains decompiler
// Type: Netick.NetworkBool
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

using System;

#nullable disable
namespace Netick;

/// <summary>
/// Always use NetworkBool instead of bool, for networked properties and RPC parameters.
/// </summary>
[Serializable]
public struct NetworkBool(bool value) : IEquatable<NetworkBool>
{
  public int RawValue = value ? 1 : 0;

  public bool ToBool() => this.RawValue == 1;

  public static bool operator ==(bool a, NetworkBool b) => a == (b.RawValue == 1);

  public static bool operator !=(bool a, NetworkBool b) => a != (b.RawValue == 1);

  public static bool operator ==(NetworkBool a, bool b) => b == (a.RawValue == 1);

  public static bool operator !=(NetworkBool a, bool b) => b != (a.RawValue == 1);

  public static bool operator ==(NetworkBool a, NetworkBool b) => a.RawValue == b.RawValue;

  public static bool operator !=(NetworkBool a, NetworkBool b) => a.RawValue != b.RawValue;

  public static implicit operator NetworkBool(bool val) => new NetworkBool(val);

  public static implicit operator bool(NetworkBool val) => val.RawValue == 1;

  public bool Equals(NetworkBool other) => this.RawValue == other.RawValue;

  public override bool Equals(object obj)
  {
    return obj is NetworkBool networkBool && networkBool.RawValue == this.RawValue;
  }

  public override int GetHashCode() => this.RawValue;

  public override string ToString() => this.RawValue != 1 ? "false" : "true";
}
